import * as types from '../constants/ActionTypes';
export default function rechargeconfig(state = [], action = {}) {
    const {
        type, payload
    } = action;
    switch (type) {
        //============================================================
        //获取订单号信息
        //============================================================
        case types.FETCH_RECHARGE_CONFIG:
            return {...payload };
        case types.FETCH_RECHARGE_CONFIG_SUCCESS:
            return payload.results[0];
        case types.FETCH_RECHARGE_CONFIG_FAILURE:
            return [];

        //============================================================
        //查询支付状态信息
        //============================================================
        case types.FETCH_RECHARGE_STATUS:
            return {...payload };
        case types.FETCH_RECHARGE_STATUS_SUCCESS:
            let resultInfo;
            if (payload && payload.results && parseInt(payload.results[0].status) == 1) {
                resultInfo = {
                    recharge_result_status : 1,
                    message : "充值成功",
                    result : payload.results[0]
                };
            }else{
                resultInfo = {
                    recharge_result_status : -1,
                    message : "充值失败"
                };
            }
            return resultInfo;
        case types.FETCH_RECHARGE_STATUS_FAILURE:
            let failureInfo = {
                recharge_result_status : -1,
                message : "充值失败"
            };
            return failureInfo;
        default:
            return state;
    }
}